home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / GRAPHICS / UVE138.ZIP / EXAMPLES.ZIP / SPHERE.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-08-30  |  1.3 KB  |  72 lines

  1. {$A+,B-,D+,E+,F-,G+,I+,L+,N-,O-,P-,Q-,R-,S+,T-,V+,X+}
  2. {$M 16384,0,655360}
  3.  
  4. {
  5. SPHERE.PAS
  6. Demonstrates     - sprite loading
  7.         - sprite chaining
  8.         - higher level of sprite encapsulation
  9. }
  10.  
  11.  
  12. uses    crt,uve32;
  13.  
  14. const    maxspheres=20;
  15.  
  16. type    spheretype=record
  17.         x,y,
  18.         forcex,forcey:longint;
  19.     end;
  20.  
  21. var    sphere:array[1..maxspheres] of spheretype;
  22.  
  23. procedure init;
  24. var    pal:palette;
  25.     i:integer;
  26. begin
  27.     ia_inituve;
  28.     ia_loadspr('sphere.uvl',1);
  29.     ia_loadpalette('sphere.pal',pal);
  30.     ia_chainsprite(1,spritesloaded,1);
  31.     ia_powerup;
  32.     ia_setpalette(pal);
  33.     ia_setcycletime(40);
  34.     for i:=1 to maxspheres do with sphere[i] do begin
  35.         x:=longint(random(320))*256;
  36.         y:=longint(random(180))*256;
  37.         forcex:=(longint(random(10))-5)*256;
  38.         forcey:=(longint(random(10))-5)*256;
  39.         spr[i].n:=1+random(30);
  40.     end;
  41. end;
  42.  
  43. procedure deinit;
  44. begin
  45.     ia_shutdown;
  46.     halt;
  47. end;
  48.  
  49.  
  50. procedure movespheres;
  51. var    i:integer;
  52. begin
  53.     for i:=1 to maxspheres do with sphere[i] do begin
  54.         inc(x,forcex);
  55.         inc(y,forcey);
  56.         if (y>200*256) and (forcey>0) then
  57.             forcey:=-forcey
  58.             else inc(forcey,64);
  59.         if (x<0) and (forcex<0) then forcex:=-forcex;
  60.         if (x>320*256) and (forcex>0) then forcex:=-forcex;
  61.         ia_center(i,x div 256,y div 256,2);
  62.     end;
  63. end;
  64.  
  65. begin
  66.     init;
  67.     repeat
  68.         movespheres;
  69.         ia_doframe;
  70.     until keypressed;
  71.     deinit;
  72. end.